-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-file Typescript support in vscode-web #169311
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Because I dont have the default browser set up correctnly on any of my machiens
And some logging as I figure out how to use it
Use webpack's CopyPlugin transform pattern to do this manually. This is probably a bad idea! It's just for prototyping purposes.
Nonetheless required for it to work!
Another typo. Guess my local test wasn't running the contents really
Also: - tsserver.js is no longer minified - log crossOriginIsolated
Because it's browser-specific
Build only the ts parts of tsserver.web.js, don't rebuild the vscode extension. This is a lot faster.
Sheetal showed me the correct way to create a verbose logger instead.
And make isWeb support semantic mode.
Also paste in some example code for cancellation, which is not finished at all.
1. Remove a little logging. 2. Correct failure return value for getFileSize 3. Reorder some methods and parameters.
I'm not sure if it's OK to depend on a module from another extension; it's probably better to include the files from a central place instead.
1. Copy and adapt implementations from node host where possible. 2. Note questions for the PR elsewhere. 3. Remove logging except for caught exceptions.
Also gate it behind a check to `crossOriginIsolated`
It won't minimise it *much*, but I also consolidated some unnecessarily-spread-out code that will be easier to read in the long term, and possibly easier to read in diff form as well.
Copy from markdown extension to typescript extension. I used the existing dependencies in the typescript extension, but verified that they would work the same.
…y prefix when project wide intellisense is disabled
Symlinks are implicitly supported by the filesystem right now.
There are 3 build failures right now:
@mjbvz I think only the last failure needs to be fixed. I'm investigating but you might be faster than me. Edit: The failing task is extensions-ci There might be an established way to add dependencies that's not PRs, in which case (2) will need to be addressed that way. |
mjbvz
approved these changes
Jan 12, 2023
Tyriar
approved these changes
Jan 12, 2023
🥳 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds cross-file Typescript support to vscode-web. Like the desktop version, it starts two tsservers, one in syntax mode and one in semantic mode. This means that you can now import from from other files without having them open in the editor.
It does this by changing the web-based tsserver host, which now depends on vscode-wasm to communicate with a virtual file system. The code is substantially similar to before, but supports slightly more of the tsserver API, and adds a translation layer for talking to a virtual file system based on URIs instead of a real one based on paths. It also has adapter code for responding to watch events asynchronously but communicating the event to tsserver sychronously.
It makes some important changes to the typescript extension:
I don't know if any of these are done in the right place, or in the right way. I also have some questions about the host implementation:
For @sheetalkamat:
require
-- is this needed? In TS, it's only used in project system. Answer: No, only needed for node environments.trace
-- is this needed? In TS, it's only used in project system. Answer: No.useCaseSensitiveFileNames
-- old version says 'false' is the safest option, but the virtual fs is case sensitive. Isfalse
still better? Answer: match the virtual fs: case-sensitive.For @jrieken:
writeOutputIsTTY
-- I'm using apiClient.vscode.terminal.write -- is it a tty?getWidthOfTerminal
-- I don't know where to find this on apiClient.vscode.terminal eitherclearScreen
-- the node version of the code writes \x1BC to the terminal. Would this work for vscode?readFile/writeFile
-- the node version handles utf8, utf16le and manually converts big-endian to utf16 little-endian. How does the in-memory filesystem handle this? There's no place to specify encoding.realpath
/getDirectories
/readDirectory
-- how do I resolve symlinks? I copied somefs.statSync
-based code for getDirectories, but I don't think it's right.Not sure who will know these:
resolvePath
-- node version uses path.resolve. Is it OK to use that? Or should I re-implement it? Just use identity like the old web code?createSHA256Hash
-- the browser version is async, so I skipped it. Is this OK?This PR still needs some cleanup, which I will do next:
isWeb()
is a way to check for being on the webThese are tracked in the PR itself in extensions/typescript-language-fetaures/web/README.md